package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhSupplierGoodSpec;
import com.ruoyi.xh.service.IXhSupplierGoodSpecService;

/**
 * 商品规格Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "商品规格Controller",value = "商品规格Controller")
@RestController
@RequestMapping("/xh/supplierGoodSpec")
public class XhSupplierGoodSpecController extends BaseController {

    @Autowired
    private IXhSupplierGoodSpecService xhSupplierGoodSpecService;

    /**
     * 查询商品规格列表
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierGoodSpec:list')")
    @GetMapping("/list")
    @ApiOperation("查询商品规格列表")
    public TablePageDataInfo<XhSupplierGoodSpec> list(XhSupplierGoodSpec xhSupplierGoodSpec) {
        return TablePageDataInfo.success(xhSupplierGoodSpecService.selectXhSupplierGoodSpecList(xhSupplierGoodSpec));
    }

    /**
     * 获取商品规格详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierGoodSpec:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取商品规格详细信息")
    public CommentResult<XhSupplierGoodSpec> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhSupplierGoodSpecService.selectXhSupplierGoodSpecById(id));
    }

    /**
     * 新增商品规格
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierGoodSpec:add')")
    @Log(title = "商品规格", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增商品规格")
    public CommentResult<XhSupplierGoodSpec> add(@RequestBody XhSupplierGoodSpec xhSupplierGoodSpec) {
            xhSupplierGoodSpecService.insertXhSupplierGoodSpec(xhSupplierGoodSpec);
        return CommentResult.success();
    }

    /**
     * 修改商品规格
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierGoodSpec:edit')")
    @Log(title = "商品规格", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改商品规格")
    public CommentResult<XhSupplierGoodSpec> edit(@RequestBody XhSupplierGoodSpec xhSupplierGoodSpec) {
            xhSupplierGoodSpecService.updateXhSupplierGoodSpec(xhSupplierGoodSpec);
        return CommentResult.success();
    }

    /**
     * 删除商品规格
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierGoodSpec:remove')")
    @Log(title = "商品规格", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除商品规格")
    public CommentResult<XhSupplierGoodSpec> remove(@PathVariable Long[] ids) {
            xhSupplierGoodSpecService.deleteXhSupplierGoodSpecByIds(ids);
        return CommentResult.success();
    }
}
